package com.zsc.wxapp.services.impl;

import com.zsc.wxapp.entity.User;
import com.zsc.wxapp.entity.vo.CustomerVO;
import com.zsc.wxapp.exservices.Remote2;
import com.zsc.wxapp.mapper.CodeOfCustMapper;
import com.zsc.wxapp.mapper.CustomerOfManagerMapper;
import com.zsc.wxapp.mapper.TestMapper;
import com.zsc.wxapp.services.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import java.util.LinkedHashSet;

@Service
@Slf4j
public class TestServiceImpl implements TestService {

    @Resource
    private TestMapper testMapper;
    @Resource
    private CustomerOfManagerMapper customerOfManagerMapper;
    @Resource
    private Remote2 remote2;
    @Resource
    private CodeOfCustMapper codeOfCustMapper;

    @Override
    public User testMysql() {
        User user = testMapper.testMysql();
        return user;
    }

    /**
     * 数据插入已经完成，禁止再次插入数据
     */
    @Override
    public void processedData() {
        // 远程获取到用户的所有custUuid
        List<CustomerVO> list = remote2.getAllCustomer();

        for (CustomerVO customerVO : list) {
            //插入数据
            log.info("插入数据：{}", customerVO);
//            codeOfCustMapper.insert(customerVO.getCustCode(), customerVO.getCustUuid());
        }
    }

}
